package com.zzyl.service.impl;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageBean;
import com.zzyl.dto.DeviceDataPageReqDto;
import com.zzyl.mapper.DeviceDataMapper;
import com.zzyl.service.DeviceDataService;
import com.zzyl.vo.DeviceDataVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class DeviceDataServiceImpl implements DeviceDataService {

    @Autowired
    DeviceDataMapper deviceDataMapper;
    @Override
    public PageBean<DeviceDataVo> query(DeviceDataPageReqDto dto) {
        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
        dto.setStartDate(LocalDateTimeUtil.of(dto.getStartTime()));
        dto.setEndDate(LocalDateTimeUtil.of(dto.getEndTime()));

        Page<DeviceDataVo> deviceDataVos = deviceDataMapper.selectByPage(dto);

        return PageBean.of(deviceDataVos,DeviceDataVo.class);
    }
}
